/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author mosta
 */
public class AdminLoginDataBase {
    
    private Connection conn;
    private Statement stmt;
    private ResultSet result;
    private PreparedStatement prepStmt;

    public AdminLoginDataBase() {
        
        DatabaseConnection connection = new DatabaseConnection();
        conn = connection.startConnection();
    }
    
    public int signInAdmin(String adminName,String adminPass)
    {
        int returnedValue=0;
        String chkSql="select name from admin where name=? and passwd=? ";
        try {
            prepStmt = conn.prepareStatement(chkSql);
            prepStmt.setString(1,adminName);
            prepStmt.setString(2,adminPass);
            result = prepStmt.executeQuery();
            if(result.next())
            {
                returnedValue = 1;
            }
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
        return returnedValue;
    }
    
}
